bpo-46678: Fix Invalid cross device link in Lib/test/support/import_helper.py#31204
Merged
miss-islington merged 2 commits intoFeb 8, 2022
Merged
bpo-46678: Fix Invalid cross device link in Lib/test/support/import_helper.py#31204miss-islington merged 2 commits into
miss-islington merged 2 commits into
Conversation
os.rename fails if the source and target live on different devices. This can occur in Lib/test/support/import_helper.py (for example) if /tmp is mounted as a ramdisk, or more generally if PYTHONPYCACHEPREFIX is set to a directory on a different drive from where temporary files are stored.
brettcannon
approved these changes
Feb 8, 2022
Contributor
|
Sorry, I can't merge this PR. Reason: |
Contributor
|
Sorry, I can't merge this PR. Reason: |
1 similar comment
Contributor
|
Sorry, I can't merge this PR. Reason: |
Contributor
|
@notarealdeveloper: Status check is done, and it's a success ✅ . |
Contributor
|
Thanks @notarealdeveloper for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
Contributor
|
Sorry, @notarealdeveloper, I could not cleanly backport this to |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Feb 8, 2022
…elper.py (pythonGH-31204) In [Lib/test/support/import_helper.py](https://github.com/python/cpython/blob/master/Lib/test/support/import_helper.py), the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this. Automerge-Triggered-By: GH:brettcannon (cherry picked from commit da576e0) Co-authored-by: Jason Wilkes <notarealdeveloper@gmail.com>
|
GH-31207 is a backport of this pull request to the 3.10 branch. |
brettcannon
pushed a commit
that referenced
this pull request
Feb 8, 2022
…elper.py (GH-31204) (GH-31207) In `Lib/test/support/import_helper.py`, the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this. Automerge-Triggered-By: GH:brettcannon (cherry picked from commit da576e0) Co-authored-by: Jason Wilkes <notarealdeveloper@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Lib/test/support/import_helper.py, the function
make_legacy_pycmakes a call toos.renamewhich can fail when the source and target live on different devices. This happens (for example) whenPYTHONPYCACHEPREFIXis set to a directory anywhere on disk, while a ramdisk is mounted on/tmp(the latter of which is the default on various Linux distros). Replacingos.renamewithshutil.movefixes this.https://bugs.python.org/issue46678
Automerge-Triggered-By: GH:brettcannon